﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;

namespace hpm
{
    public partial class frmDanhMuc : DevExpress.XtraEditors.XtraForm
    {
        public frmDanhMuc()
        {
            InitializeComponent();
        }

        Utility hpmUtility = new Utility();
        DataTable objDatable = null;

        clsNgheNghiep objNgheNghiep;
        clsKhoa objKhoa;
        clsDanToc objDanToc;


        private void nbbtnDmNgheNghiep_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            string[] captionArray = { "Mã Nghề", "Tên Nghề", "Diễn Giải" };
            objNgheNghiep = new clsNgheNghiep();
            
            hpmUtility.addCaptionToGridView(grdDanhMuc, grvDanhMuc, objNgheNghiep.GetAll_NgheNghiep(), captionArray);
        }

        private void nvbtnDMKhoa_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            string[] captionArray = { "Mã Khoa", "Tên Khoa" };
            objKhoa = new clsKhoa();
            objDatable = objKhoa.GetAll_Khoa();

            hpmUtility.addCaptionToGridView(grdDanhMuc, grvDanhMuc, objKhoa.GetAll_Khoa(), captionArray);
        }
        

        //Add new row when type any on first Column
        private void grvDanhMuc_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            string[] maObjArr = {"Mã Nghề", "Mã Khoa" };
            hpmUtility.addNewRowToGridControl(grvDanhMuc,e.Column.ToString(), maObjArr);
        }

        private void nvbtnDmDanToc_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            string[] captionArray = { "Mã Dân Tộc", "Tên Dân Tộc", "Trạng Thái" };
            objDanToc = new clsDanToc();
            objDatable = objDanToc.getAllDanToc();

            hpmUtility.addCaptionToGridView(grdDanhMuc, grvDanhMuc, objDatable, captionArray);
        }

        
        
       
    }
}